package controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import broker.UrlBroker;

/**
 * Servlet implementation class StartBroker
 */
@WebServlet("/StartBroker")
public class StartBroker extends HttpServlet {
	private static final long serialVersionUID = 1L;
	private static UrlBroker broker;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		StartBroker.start();
	}

	public static void main(String[] args) {
		StartBroker.start();
	}

	public static void start() {
		broker = new UrlBroker();
		broker.start();
	}

	@SuppressWarnings("deprecation")
	public static void stop() {
		broker.stop();
		broker.destroy();
	}

}
